package org.gd136.ce.script.impl;

import org.gd136.ce.script.Script;
import org.gd136.ce.script.ScriptStage;

public class OptionScript extends Script {
	String text;

	private static final String TAG = "#option ";

	@Override
	public Script readScript(String scriptLine) {
		OptionScript os = null;
		if (scriptLine.startsWith(TAG)) {
			os = new OptionScript();
			os.text = scriptLine.substring(TAG.length());
			os.addToPool();

			if (SelectScript.getLastSelect() == null) {
				throw new IllegalArgumentException("Option 未处在Select之中! file["
						+ fileName + "] line[" + lineNum + "]");
			}
			SelectScript.getLastSelect().options.add(os);
		}
		return os;
	}

	@Override
	public void execute(ScriptStage stage) {
		SM.stack.add(this);
	}

	public String getText() {
		return text;
	}
}